package main;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Polygon;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class PointOfInterest implements MouseListener {

	public Point place;
	public JLabel tooltip;
	public JPanel info;
	public JButton done = new JButton("DONE");
	
	public PointOfInterest() {
		place = new Point(500, 500);
		
		tooltip = new JLabel("<html><center><b>The Eiffel Tower</b><br /><br />" +
        		"The Eiffel Tower is an 1889 iron lattice tower located on the Champ de Mars in Paris that has become both a global icon of France and one of the most recognizable structures in the world. The tallest building in Paris, it is the most-visited paid monument in the world; millions of people ascend it every year. Named for its designer, engineer Gustave Eiffel, the tower was built as the entrance arch to the 1889 World's Fair.<br /><br />" +
        		"<b>Click for more info</b><br /><br />" +
        		"Info taken from wikipedia.org</center></html>");
		
		tooltip.setPreferredSize(new Dimension(200, 400));
        
        tooltip.addMouseListener(this);
		
        info = new JPanel();
        info.setPreferredSize(new Dimension(800, 600));
        info.setLayout(new FlowLayout());
		
        JLabel label = new JLabel();
        label.setPreferredSize(new Dimension(800, 500));
        label.setFont(Fonts.default_font(22));
        label.setText("<html><center><b>The Eiffel Tower</b>" +
        		" is an 1889 iron lattice tower located on the Champ de Mars in Paris that " +
        		"has become both a global icon of France and one of the most recognizable " +
        		"structures in the world. The tallest building in Paris, " +
        		"it is the most-visited paid monument in the world; millions of people " +
        		"ascend it every year. Named for its designer, engineer Gustave Eiffel," +
        		" the tower was built as the entrance arch to the 1889 World's Fair. " +
        		"The tower stands 324 metres (1,063 ft) tall, about the same height as an " +
        		"81-storey building. Upon its completion, it usurped the Washington Monument" +
        		" to assume the title of tallest man-made structure in the world, a title it " +
        		"held for 41 years, until the Chrysler Building in New York City was built in" +
        		" 1930. Not including broadcast antennas, it is the second-tallest structure " +
        		"in France after the 2004 Millau Viaduct. The tower has three levels" +
        		" for visitors. Tickets can be purchased to ascend, by stairs or lift, to the " +
        		"first and second levels. The walk to the first level is over 300 steps, as" +
        		" is the walk from the first to the second level. The third and highest level " +
        		"is accessible only by elevator. Both the first and second levels feature " +
        		"restaurants. The tower has become the most prominent symbol of both Paris " +
        		"and France, often in the establishing shot of films set in the city.</center></html>");
        		
		done.setPreferredSize(new Dimension(800, 100));
		done.setFont(Fonts.default_font(48));
				
		info.add(label);
		info.add(done);
		
        done.addMouseListener(this);        
	}
	
	public void draw(Graphics g) {
		Polygon p = new Polygon();
		p.addPoint((int)place.x-10, (int)place.y);
		p.addPoint((int)place.x, (int)place.y-20);
		p.addPoint((int)place.x+10, (int)place.y);
		p.addPoint((int)place.x, (int)place.y+20);
				
		g.setColor(Color.ORANGE);
		
		g.fillPolygon(p);
	}

	@Override
	public void mouseClicked(MouseEvent arg0) {
		if (Simulator.timer.isRunning()) {
			return;
		}
		
		if (arg0.getSource().equals(tooltip)) {
			UserInterface.setContentPane(info);
			Simulator.setAnimation(false);
		} else if (arg0.getSource().equals(done)) {
			UserInterface.setContentPane(UserInterface.simulatorPanel);
		}
		
	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	
}
